<?php
$this->breadcrumbs=array(
	//'Coffee Recommends'=>array('index'),
	'Manage Recommends',
);

$this->menu=array(
	array('label'=>'List CoffeeRecommend', 'url'=>array('index')),
	array('label'=>'Create CoffeeRecommend', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('coffeerecommend-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Manage Coffee Recommends</h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<div class="wide form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'action'=>Yii::app()->createUrl($this->route),
	'method'=>'get',
)); ?>

	<div class="row">
		<?php echo $form->label($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>255)); ?>
	</div>


	<div class="row">
		<?php echo $form->label($model,'street'); ?>
		<?php echo $form->textField($model,'street',array('size'=>60,'maxlength'=>255)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'suburb'); ?>
		<?php echo $form->textField($model,'suburb',array('size'=>32,'maxlength'=>32)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'status'); ?>
		<?php echo $form->dropDownList($model,'status',CoffeeRecommend::status_options()); ?>
	</div>


	<div class="row buttons">
		<?php echo CHtml::submitButton('Search'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- search-form -->
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'coffeerecommend-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		//'id',
		'name',
		//'ownerName',
		//'street',
		'suburb',
		//'state',
		/*
		'postcode',
		'country',
		'website',
		'phone',
		'email',
		'baristaNames',
		'espressoMachine',
		'beansForSale',
		'internetAccess',
		'roastingOnSite',
		'coffeeBrand',
		'comment',
		'status',
		'shopId',
		*/
		array(
			'name' => 'date',
			'type'=>'raw',
			'value'=>'date("d/m/Y h:i:s",$data->date)',
			'filter'=>'',
		),
		array(
			'name' => 'status',
			'type'=>'raw',
			'value'=>'CoffeeRecommend::status_options($data->status)',
			'filter'=>CoffeeRecommend::status_options(),
		),
		array(
			'class'=>'CLinkColumn',
			'header' => 'Approve',
			      'labelExpression'=>'$data->status==CoffeeRecommend::STATUS_PENDING||$data->status==CoffeeRecommend::STATUS_REJECTED?"Approve":""',     // text label of the button
			      'urlExpression'=>'$data->status==CoffeeRecommend::STATUS_PENDING||$data->status==CoffeeRecommend::STATUS_REJECTED?CHtml::normalizeUrl(array("coffeeRecommend/approve","id"=>$data->id)):""',       // the PHP expression for generating the URL of the button
			    	// 'imageUrl'=>'...',  // image URL of the button. If not set or false, a text link is used
			     	// 'options'=>array(...), // HTML options for the button tag
			     	// 'click'=>'...',     // a JS function to be invoked when the button is clicked
				 
			
		),
		array(
			'class'=>'CLinkColumn',
			'header' => 'Reject',
				      'labelExpression'=>'$data->status!=CoffeeRecommend::STATUS_PENDING?"":"Reject"',     // text label of the button
				      'urlExpression'=>'$data->status!=CoffeeRecommend::STATUS_PENDING?"":CHtml::normalizeUrl(array("coffeeRecommend/reject","id"=>$data->id))',       // the PHP expression for generating the URL of the button
				     // 'imageUrl'=>'...',  // image URL of the button. If not set or false, a text link is used
				     // 'options'=>array(...), // HTML options for the button tag
				     // 'click'=>'...',     // a JS function to be invoked when the button is clicked
			
			
		),
		array(
			'class'=>'CButtonColumn',
			'template'=>'{view} {delete}',
		),
	),
)); ?>
